package com.company.cloud.mall.modules.utils;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.DefaultSignChecker;
import com.alipay.api.internal.util.AlipaySignature;
import com.company.cloud.common.utils.PinYinUtils;
import com.company.cloud.pay.modules.alipay.AliPayCore;
import com.company.cloud.pay.modules.alipay.enums.SignType;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.Week;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;

public class ShopNoUtils {

	/**订单编号*/
	public static String getOrderSn() {
		return StrUtil.format("DD_{}", IdUtil.getSnowflake(1, 1).nextIdStr());
	}
	
	
	/**订单发货流水号*/
	public static String getShippingOrderSn() {
		return StrUtil.format("DS_{}", IdUtil.getSnowflake(2, 1).nextIdStr());
	}
	
	/**支付流水号*/
	public static String getPayOrderSn() {
		return StrUtil.format("PS_{}", IdUtil.getSnowflake(3, 1).nextIdStr());
	}
	
	
	/**退款流水号*/
	public static String getRefundSn() {
		return StrUtil.format("RS_{}", IdUtil.getSnowflake(3, 1).nextIdStr());
	}
	
	/**订单退款流水号*/
	public static String getOrderRefund() {
		return StrUtil.format("RF_{}", IdUtil.getSnowflake(4, 1).nextIdStr());
	}
	
	/**订单退货退款流水号*/
	public static String getOrderReturn() {
		return StrUtil.format("RPF_{}", IdUtil.getSnowflake(5, 1).nextIdStr());
	}
	
	
	/**订单兑换码*/
	public static String getOrderExchangeCode() {
		return IdUtil.getSnowflake(7, 1).nextIdStr();
	}
	
	
//	/**商家编号*/
//	public static String getBusinessNo() {
//		return StrUtil.format("B{}", IdUtil.getSnowflake(1, 2).nextIdStr());
//	}
	
	
	public static void main(String[] args) {
//		System.out.println(DateUtil.now());
//		Week week=DateUtil.thisDayOfWeekEnum();
//		System.out.println(DateUtil.thisDayOfWeek());
//		int week=DateUtil.thisDayOfWeek();
//		if(week==1) { //日
//			
//		}else {
//			
//		}
		
//		System.out.println(DateUtil.format(DateUtil.beginOfWeek(new Date()), "yyyy-MM-dd HH:mm:ss"));
//		System.out.println(DateUtil.format(DateUtil.beginOfMonth(new Date()), "yyyy-MM-dd HH:mm:ss"));
//		
		
//		System.out.println(DateUtil.thisDayOfMonth());
//		
//		System.out.println("m".toLowerCase());
		
		
//		System.out.println(StrUtil.format("{}-01 00:00:00", DateUtil.format(new Date(), "yyyy-MM")));
		 
		 Map<String, String> m=new HashMap<String, String>();
		 m.put("gmt_create", "2021-02-24 23:11:44");
		 m.put("charset", "utf-8");
		 m.put("gmt_payment", "2021-02-24 23:11:49");
		 m.put("notify_time", "2021-02-24 23:25:06");
		 m.put("subject", "商品");
		 m.put("sign", "ZjMl26kzFa35CzGHLDQpXceHIKdU+NgC5x51gRgvipy7jKm6VEGWoZyszkTzwccP1vEMYeb9Y8EFE92a9tmY1RVVzmQnZRh8NGOajVMj05Q4SqxQQsfuU89xpLH0KY/mglg53ozUsMA+rjgeWvMK3lX2fN5CMKeELuIbAos+QkIcdZRRn7TTghvv7Ok5kbAVXTHsOzC7DSYjaIVSQkZ95ZUTwDCUpVkOxI/zETGsHZcOH3XmFIcqUKriOg8oZDsdASqJCcWGF09KzJBqp5D7Z6+ZdFtUshHv1UNAenKyzQJE+T4NWfdZ1EpZKsuOA+0QfeMMSJwGlZB4IXyuO2bUXQ==");
		 m.put("buyer_id", "2088022675845593");
		 m.put("invoice_amount", "0.03");
		 m.put("version", "1.0");
		 m.put("notify_id", "2021022400222231149045591449970662");
		 m.put("fund_bill_list", "[{\"amount\":\"0.03\",\"fundChannel\":\"PCREDIT\"}]");
		 m.put("notify_type", "trade_status_sync");
		 m.put("out_trade_no", "PS_1364593809916309504");
		 m.put("total_amount", "0.03");
		 m.put("trade_status", "TRADE_SUCCESS");
		 m.put("trade_no", "2021022422001445591439216936");
		 m.put("auth_app_id", "2021002128601544");
		 m.put("receipt_amount", "0.03");
		 m.put("point_amount", "0.00");
		 m.put("buyer_pay_amount", "0.03");
		 m.put("sign_type", "RSA2");
		 
		 

		 Map<String, String> m2=AliPayCore.paraFilter(m);
		 
		 String sourceContent= AliPayCore.createLinkString(m);
		  System.out.println(sourceContent);
		 
		 
		  
		  String alipayPublicKey="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxRHuMPOnfJ5GqMf7Pw92nf5790hQOU9TDRgc0gVP311DEyKuWmIOva98jJiBhe73akiM6eUyMKW8X9b2MZqJ1nDeeQtMspKsYOUC5i7WAfmy3msZrJscC+BlWg1C/kbeAhhH+l6MBJ9Ng4CH+edlvaYr+Rpxv0DWeqhSq0+Q7DdA0LE939fOerqEiQMPRhq3UPjC4O+IiuA+lqMlQnkRC1JZI3IaC6CmNYSbB3J6BB9eFPo2nOxzIwpLQX/KcPb7ASfARFkI/DEQNW0f8owlGEP3/cdH+wkHEu5qJxrxHJF97eGGorhjDH1Fp9tpmHhPy86lhZYkwS+ShsfHDNu7UQIDAQAB";
//		  String alipayPublicKey= "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnWwlwJWLx6zbuA/jHeOU0CHBEfIRJzIaHRQ0CE/0CHIUfWK8c31btdWZAZns2iKN04CFECO+RMow0daZEi+PT3krbpkimRabJzJOHGu4t29GN8r37pybwfp7jEC6HHSwyiPqoTtYtatcon2yCHlf7N6BICCzw2UsGYA3ST/eYcfPRG4rRfGYHqSrNJZ2Nmx0XQAMidMa/M96BCxKV+z4SU/SLuFGTG7yupobtVGer8UHi+BmyghymVa0uejAXB4StgUL2mixJMMMaxbyjLDVbQ+f3uKNrawGaqUptHstp5IvkSHArLV6MAEwVIxE47oTFOLS56dKJgzZPjxMoyzp6QIDAQAB";

		 
//			String alipayPublicKey="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnWwlwJWLx6zbuA/jHeOU0CHBEfIRJzIaHRQ0CE/0CHIUfWK8c31btdWZAZns2iKN04CFECO+RMow0daZEi+PT3krbpkimRabJzJOHGu4t29GN8r37pybwfp7jEC6HHSwyiPqoTtYtatcon2yCHlf7N6BICCzw2UsGYA3ST/eYcfPRG4rRfGYHqSrNJZ2Nmx0XQAMidMa/M96BCxKV+z4SU/SLuFGTG7yupobtVGer8UHi+BmyghymVa0uejAXB4StgUL2mixJMMMaxbyjLDVbQ+f3uKNrawGaqUptHstp5IvkSHArLV6MAEwVIxE47oTFOLS56dKJgzZPjxMoyzp6QIDAQAB";

		  
//		  try {
//			  boolean f= AlipaySignature.rsaCheckV2(m, alipayPublicKey, "utf-8", "RSA2");
//			  System.out.println(f);
//		  } catch (AlipayApiException e) {
//			e.printStackTrace();
//		  }
		  


		  
		  //			DefaultSignChecker s=new DefaultSignChecker(alipayPublicKey);
//			
//			boolean f= s.check(sourceContent, m.get("sign"), "RSA2", "utf-8");
//		 System.out.println(f);
		 
//			String sign= AliPayCore.buildRequestMySign(m2, payConfig.getPayChannelParam().getAliPrivateKey(), SignType.MD5.getType());
			
		
		 
		
	}
	
	
	
}
